﻿@using Pay.Token.Utils;
@model PagedResult<token_shop_subject_product_dto>
@{
    var img_url = ViewBag.img_url;
    var shop_id = ViewBag.shop_id;
    int userType = ViewBag.UserType;
    if (Model.rows.Count > 0) {
        foreach (var item in Model.rows) {
            <div class="item">
                <a href="/DistributionMall/ProductDetail?productId=@item.product_id&shopId=@shop_id" target="_blank">
                    <div class="itemBox">
                        <div class="img">
                            <img src="@(item.product.main_image_url)" />
                        </div>
                        <div class="box">
                            <p class="tit">@item.product.name</p>
                            <div class="mb20">
                                <p>
                                    @if (item.product.price > 0) {
                                        <em class="col-red fn20">￥</em>
                                        <span class="col-red fn32">@item.product.price.ToString("0.##")</span>
                                    }

                                    @if (item.product.activity_ex != null && item.product.price > 0 && item.product.activity_ex.activity_red_drill > 0) {
                                        <span class="col-red">+</span>
                                    }

                                    @if (item.product.activity_ex != null && item.product.activity_ex.activity_red_drill > 0) {
                                        <span class="col-red fn32">@item.product.activity_ex.activity_red_drill.ToString("0.######")</span> <em class="col-red fn20">红钻</em>
                                    }
                                </p>
                                <p style="white-space:nowrap;">
                                    <em class="col-red fn20">收益</em>
                                    <span class="col-red fn28 fontweight">
                                        @if (userType > 0) {
                                            @(DistributionHelper.GetProfitByLevel(item.product.distribution_price.GetValueOrDefault(0), (UserType)ViewBag.UserType).ToString("f2"))
                                        } else {
                                            @((item.product.distribution_price.GetValueOrDefault(0) * 0.1M).ToString("f2") + "～" + item.product.distribution_price.GetValueOrDefault(0).ToString("f2"))
                                        }
                                    </span>
                                </p>
                            </div>
                            @if (!(item.product.activity_ex != null && (item.product.activity_ex.activity_type == EActivityType.ProductMaker || item.product.activity_ex.activity_type == EActivityType.ProductOnlyRedDrill))
                                 && item.product.price > 0) {
                                <span class="ui-btn-share ui-btn-share-100 fxPro" href="javascript:void(0)"
                                      data-main_image_url="@(item.product.main_image_url)" data-price="@item.product.price" data-cost-price="@item.product.market_price.ToString("0.##")" 
                                      data-red-drill="@((item.product.activity_ex != null ? item.product.activity_ex.activity_red_drill : 0).ToString("0.######"))"
                                      data-name="@(item.product.name.Length > 30 ? item.product.name.Substring(0, 30) : item.product.name)" data-id="@item.product.id">立即分享</span>
                            }
                        </div>
                    </div>
                </a>
            </div>
        }
    }
    <page total_pages="@Model.total_pages" rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}
@*<script type="text/javascript">
        $(function () {
            // 瀑布流
            $('.wall').jaliswall({ item: '.item' });
        })
    </script>*@
